#include "historyproductsaletableview.h"
#include "readonlydelegate.h"

HistoryProductSaleTableView::HistoryProductSaleTableView(QWidget *parent) : MyTableView(parent)
{
    model = new HistoryProductStandardItemModel();
    setModel(model);

    for(int i=0;i<model->columnCount()-1;i++){
        setItemDelegateForColumn(i, new ReadOnlyDelegate());
    }
}

void HistoryProductSaleTableView::setListPushButton(ListPushButton *listPushButton){
    setListPushButtonAndMenuLabel(listPushButton, model->header);
}

void HistoryProductSaleTableView::initHiddenState(){
    initHiddenStateList("sale/historyProduct", model->header.size());
}

void HistoryProductSaleTableView::clear(){
    model->reset();
}

void HistoryProductSaleTableView::insertHistoryProduct(QList<HistoryProduct*> historyProducts){
    model->insertHistoryProduct(historyProducts);
}

QList<HistoryProduct*> HistoryProductSaleTableView::getEditedHistoryProducts(){
    return model->getEditedHistoryProducts();
}
